import LinkList.DoubleLinkList;
import LinkList.Queue;
import LinkList.Stack;

/**
 * 主函数
 *
 * @author Delouch
 * @date 2024-10-18 09:49:49
 */

public class Main {

    public static void main(String[] args) {
        testQueue();
    }

    static void testQueue() {
        Queue<Integer> queue = new Queue();
        for (int i = 0; i < 10; i++) {
            queue.pop(i);
        }
        System.out.print(queue);

        while (!queue.isEmpty()) {
            System.out.print(queue.push());
            System.out.print("\n");
        }
    }

    static void testStack() {
        Stack<Integer> stack = new Stack();
        for (int i = 0; i < 10; i++) {
            stack.pop(i);
        }
        System.out.print(stack);

        while (!stack.isEmpty()) {
            System.out.print(stack.push());
            System.out.print("\n");
        }
    }

    static void testLinkList() {
        //        SingleLinkList<Integer> linkList = new SingleLinkList<>();

        DoubleLinkList<Integer> linkList = new DoubleLinkList<>();

        for (int i = 0; i < 10; i++) {
            /// 0   1   2   3   4   5   6   7   8   9
            linkList.add(i);
        }
        System.out.println(linkList);

        for (int i = 0; i < 10; i++) {
            /// 0  100  1  101  2  102  3  103  4  104  5  105  6  106  7  107  8  108  9  109
            linkList.insert(i + 100, i * 2 + 1);
        }
        System.out.println(linkList);

        for (int i = 0; i < 3; i++) {
            linkList.removeFirst();
        }
        System.out.println(linkList);

        for (int i = 0; i < 3; i++) {
            linkList.removeLast();
        }
        System.out.println(linkList);

        for (int i = 0; i < 3; i++) {
            linkList.remove(i * 20);
            System.out.println(linkList);
        }

        while (!linkList.isEmpty()) {
            System.out.print(linkList.removeLast());
            System.out.print("\n");
        }
        System.out.print(linkList.first());
        System.out.print("\n");
        System.out.print(linkList.last());
        System.out.print("\n");
    }

}

